// ejs文件的引入
import indexEjs from '$v/index'
import adminApi from '$a/adminApi'
async function logout(){
    console.log(1);
    let {code,msg} = await adminApi.logout()
    console.log(code,msg);
    if(!code){
        console.log(code);
        toastr.success(msg)
        localStorage.removeItem('token')
        ROUTER.go(LOGIN)
    }
}
export default function indexController(){
    return async (req, res, next) => {
        // const { params, query, body, url, route } = req
        // res.render('我是index页面')
        // 二级路由需要用到 next() 方法传递下去，以及 res.subRoute() 生成二级页面渲染的节点
        next(indexEjs({
            url: req.url,
            subRoute: res.subRoute()
        }))
        $('#logoutBtn').on('click',logout)
    }
}